<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>

<script type="text/javascript">

var  adres= document.location.href;
    function Printing(parentDiv, childDiv , parentDiv2 , childDiv2) 
    {
    	var czesc = adres.split('index.jsp?add=');
    	var adres2=czesc[0]+czesc[1]+".jsp";   	
        var mywindow = window.open(adres2, 'my div', 'height=500,width=300');
        jQuery(mywindow).bind("load",function(){

        	   if (childDiv == parentDiv) {
                
              }
              else if (mywindow.document.getElementById(childDiv)) {     
                   var child = mywindow.document.getElementById(childDiv);
                   var parent = mywindow.document.getElementById(parentDiv);
                   parent.removeChild(child);
              }
              else {
                
                   return false;
              }
        	   
        	   if (childDiv2 == parentDiv2) {
                   
               }
               else if (mywindow.document.getElementById(childDiv2)) {     
                    var child = mywindow.document.getElementById(childDiv2);
                    var parent = mywindow.document.getElementById(parentDiv2);
                    parent.removeChild(child);
               }
               else {
                 
                    return false;
               }
        	   
        	   
        	
        	mywindow.print(); 
        	mywindow.close(); });
 
        return true;
    }
</script>





<link href="style2.css" rel="stylesheet" type="text/css" />
<f:subview id="statistics">
	<a4j:loadBundle var="msg" basename="messages_#{localManager.local}"></a4j:loadBundle>
	<h:form style="overflow:auto">
		<div id="non-printable">
			<div id="test2">
				<tr:document>
					<tr:chart id="char1" tooltipsVisible="true" partialTriggers="guzik"
						legendPosition="top" value="#{statisticsManager}"
						type="#{statisticsManager.selectedTypWykresu}"
						animationDuration="2000"
						perspective="#{statisticsManager.perspektywa}"
						shortDesc="wykres 1 " inlineStyle="width:1000px; height: 500px;" />
				</tr:document>


				<a4j:commandButton styleClass="RFbutton"
					value="#{msg['kurier.konfiguruj']}" 
					oncomplete="#{rich:component('config')}.show()">
				</a4j:commandButton>
				<a href="../Faces/index.jsp?add=/kurier/statistics" class="RFbutton">
					<h:outputText id="konfig" value="#{msg['kurier.generuj']}"></h:outputText>
				</a>
			</div>
		</div>

		<br></br>
		<div id="test">
			<rich:dataTable styleClass="printable" id="dataList"
				value="#{statisticsManager.dataList}" var="dataItem" reRender="ds"
				onRowContextMenu="row=this; alert(this);"
				onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
				onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
				cellpadding="0" cellspacing="0" border="0" rows="20">

				<f:facet name="header">
					<h:outputText value="#{statisticsManager.tytul}" />
				</f:facet>


				<rich:column sortBy="#{dataItem.data}" style="width:80px">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.data']}" />
					</f:facet>
					<h:outputText value="#{dataItem.data}" />
				</rich:column>

				<rich:column sortBy="#{dataItem.positionY}" style="width:70px">
					<f:facet name="header">
						<h:outputText value="#{msg['kurier.wartosc']}" />
					</f:facet>
					<h:outputText value="#{dataItem.positionY}" />
				</rich:column>


				<f:facet name="footer">
					<rich:datascroller id="ds" align="center" for="dataList"
						maxPages="20" />
				</f:facet>
			</rich:dataTable>

			<rich:messages id="mymessages" globalOnly="true" style="color:red" />

			<div id="non-drukuj">
				<h:commandButton id="drukujButton"
					onclick="Printing('non-printable','test2', 'test','non-drukuj'); return false;"
					styleClass="RFbutton" value="Drukuj"></h:commandButton>
			</div>
		</div>



	</h:form>



	<rich:modalPanel id="config" domElementAttachment="parent"
		autosized="true" width="500" height="350">
		<f:facet name="header">
			<h:outputText id="addLabel" value="#{msg['kurier.konfiguruj']}"></h:outputText>
		</f:facet>
		<f:facet name="controls">
			<h:graphicImage value="/images/close2.png" styleClass="hidelink"
				id="hidelink1" />
			<rich:componentControl for="config" attachTo="hidelink1"
				operation="hide" event="onclick" />

		</f:facet>


		<h:form>
			<a4j:outputPanel>
				<h:panelGrid columns="2" border="0">
					<h:outputLabel for="typWykresu"
						value="#{msg['kurier.typ.wykresu']}:" />
					<h:selectOneMenu id="typWykresu"
						value="#{statisticsManager.selectedTypWykresu}" immediate="true">
						<f:selectItems value="#{statisticsManager.typWykresu}" />
						<a4j:support event="onchange" ajaxSingle="true"
							action="#{statisticsManager.changeTyp}">
						</a4j:support>
					</h:selectOneMenu>

					<h:outputLabel for="perspektywa"
						value="#{msg['kurier.perspektywa']}:" />
					<h:selectBooleanCheckbox id="perspektywa"
						value="#{statisticsManager.perspektywa}">
						<h:outputText value="2.5D"></h:outputText>
					</h:selectBooleanCheckbox>


					<h:outputLabel for="typy" value="#{msg['kurier.dane']}:" />
					<h:selectOneMenu id="typy" value="#{statisticsManager.selectedTyp}"
						immediate="true">
						<f:selectItems value="#{statisticsManager.typy}" />

					</h:selectOneMenu>

					<h:outputLabel for="od" value="#{msg['kurier.od']}:" />
					<rich:calendar id="od" value="#{statisticsManager.dataOd}"
						ajaxSingle="true" immediate="true"
						direction="top-right"
						locale="#{statisticsManager.calendar.locale}"
						popup="#{statisticsManager.calendar.popup}"
						datePattern="#{statisticsManager.calendar.pattern}"
						cellWidth="24px" cellHeight="22px" style="width:200px" />

					<h:outputLabel for="do" value="#{msg['kurier.do']}:" />
					<rich:calendar id="do" value="#{statisticsManager.dataDo}"
						ajaxSingle="true" immediate="true"
						direction="top-right"
						locale="#{statisticsManager.calendar.locale}"
						popup="#{statisticsManager.calendar.popup}"
						datePattern="#{statisticsManager.calendar.pattern}"
						cellWidth="24px" cellHeight="22px" style="width:200px" />

					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.zapisz']}"
						action="#{statisticsManager.save}" reRender="dataList"
						oncomplete="if (#{facesContext.maximumSeverity==null}) {#{rich:component('config')}.hide();}" />
					<a4j:commandButton styleClass="RFbutton"
						value="#{msg['kurier.zlec.edit.anuluj']}"
						action="#{statisticsManager.test}"
						onclick="#{rich:component('config')}.hide(); return false;" />
				</h:panelGrid>

				<rich:messages id="mymessages" globalOnly="true" style="color:red" />
			</a4j:outputPanel>
		</h:form>
	</rich:modalPanel>





</f:subview>
